# 1. 定义模型序列化器
from rest_framework import serializers

from contents.models import ContentCategory, Content


class ContentSerializer(serializers.ModelSerializer):

    class Meta:
        model = Content
        fields = '__all__'


class ContentCategorySerializer(serializers.ModelSerializer):
    content_set = ContentSerializer(many=True)

    class Meta:
        model = ContentCategory
        fields = '__all__'  # 所有字段